package com.ljh.booksysms.controller;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.ljh.booksysms.pojo.UserInfo;
import com.ljh.booksysms.service.UserInfoServices;
import com.ljh.booksysms.service.impl.UserInfoServicesImpl;

@Controller
@RequestMapping(value="/userInfo")
public class UserInfoController {
	
	@RequestMapping(value = "/login")
	public String Login(UserInfo userInfo, HttpSession session) {

		UserInfoServices uiServices = new UserInfoServicesImpl();
		UserInfo uInfo = uiServices.userLogin(userInfo);
		System.out.println(JSON.toJSONString(userInfo));
		session.setAttribute("userinfo", uInfo);
		
		if (uInfo != null) {
			
			return "forward:/bookInfo/findAllBook";
			
		} else {
			
			return "login";
		}
	}

}
